package cn.lili.controller.feign.system;

import cn.lili.modules.system.client.RegionQddClient;
import cn.lili.modules.system.client.RegionYbjClient;
import cn.lili.modules.system.entity.dos.Region;
import cn.lili.modules.system.entity.dos.RegionQdd;
import cn.lili.modules.system.entity.dos.RegionYbj;
import cn.lili.modules.system.service.RegionQddService;
import cn.lili.modules.system.service.RegionService;
import cn.lili.modules.system.service.RegionYbjService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequiredArgsConstructor
public class RegionYbjFeginController implements RegionYbjClient {

    @Resource
    private RegionYbjService regionYbjService;
    @Resource
    private RegionService regionService;


    /**
     * 根据地址Code获取地址
     *
     * @param code
     */
    @Override
    public RegionYbj getRegionYbj(String code) {
        return regionYbjService.getRegionYbj(code);
    }

    /**
     * 根据 商城地址ID  查询 企叮咚地址
     *
     * @param reginId 商城地址ID
     */
    @Override
    public RegionYbj getRegionYbjById(String reginId) {
        Region byId = regionService.getById(reginId);
        return getRegionYbj(byId.getAdCode().replaceAll("0+$", ""));
    }

    @Override
    public RegionYbj getRegionYbjByYbjId(String reginId) {
        return regionYbjService.getById(reginId);
    }
}
